<template>
  <div class="icons">
    <swiper :options="iconsOption">
      <swiper-slide
        v-for="(page,index) of pages"
        :key="index"
      >
        <div
          class='icon'
          v-for="item of page"
          :key="item.id"
        >
          <span class="img"></span>
          <p class='text'>{{item.text}}</p>
        </div>
      </swiper-slide>
      <!-- <div class="swiper-pagination1"  slot="pagination"></div> -->
    </swiper>
  </div>
</template>

<script>
export default {
  name: "HomeIcons",
  data() {
    return {
      iconsOption: {
        // pagination:'.swiper-pagination1',	// 添加轮播点
        // loop:true, //轮播可循环
        autoplay: false
      },
      list: [
        {
          id: "0001",
          imgUrl: "",
          text: "经典1"
        },
        {
          id: "0002",
          imgUrl: "",
          text: "经典2"
        },
        {
          id: "0003",
          imgUrl: "",
          text: "经典3"
        },
        {
          id: "0004",
          imgUrl: "",
          text: "经典4"
        },
        {
          id: "0005",
          imgUrl: "",
          text: "经典5"
        },
        {
          id: "0006",
          imgUrl: "",
          text: "经典6"
        },
        {
          id: "0007",
          imgUrl: "",
          text: "经典7"
        },
        {
          id: "0008",
          imgUrl: "",
          text: "经典8"
        },
        {
          id: "0009",
          imgUrl: "",
          text: "经典9"
        }
      ]
    }
  },
  computed: {
    pages() {
      const pages = []
      this.list.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang="stylus" scoped>
@import '~styles/variavle'
.icons>>>.swiper-container
  height: 0
  padding-bottom: 50%
  background: #808080
.icon
  overflow: hidden
  height: 0
  width: 25%
  float: left
  padding-bottom: 25%
  background: #808080
  font-size: 0.2rem
  border: 1px solid #fff
  box-sizing: border-box
  position: relative
  .img
    display block
    position: absolute
    top 0
    left 0
    right 0
    bottom 0.44rem
    background-color #eee
  .text
    position absolute
    height 0.44rem
    line-height 0.44rem
    text-align center
    color #fff
    padding 0
    margin 0
    left 0
    right 0
    bottom 0
    ellipsis()
</style>
